package com.hontech.bread.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bread.R
import com.hontech.bread.device.breadDownMotorBottom
import com.hontech.bread.device.breadDownMotorTop
import com.hontech.bread.ui.dialog.runProg
import com.hontech.bread.utils.onClick
import com.hontech.bread.utils.stringById

class BreadDownMotorParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_bread_down_motor, this)
        val up = view.findViewById<Button>(R.id.id_bread_down_up)
        val down = view.findViewById<Button>(R.id.id_bread_down_down)

        up.onClick {
            runProg(stringById(R.string.t1733460848_394), stringById(R.string.t1733460848_395)) {
                breadDownMotorTop()
            }
        }

        down.onClick {
            runProg(stringById(R.string.t1733460848_396), stringById(R.string.t1733460848_397)) {
                breadDownMotorBottom()
            }
        }
    }
}

